package com.example.administrator.myapplication.activity;


import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.example.administrator.myapplication.R;
import com.example.administrator.myapplication.fragment.CourseFragment;
import com.example.administrator.myapplication.fragment.ExercisesFragment;
import com.example.administrator.myapplication.fragment.MyFragment;

import static com.example.administrator.myapplication.R.*;

public class MainActivity extends AppCompatActivity {
    android.app.FragmentManager fragmentManager;
    android.app.FragmentTransaction fragmentTransaction;
    ImageView courseImg;
    ImageView exerciseImg;
    ImageView myImg;
    TextView courseText;
    TextView exerciseText;
    TextView myText;

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(layout.activity_main);
        fragmentManager=getFragmentManager();
        fragmentTransaction=fragmentManager.beginTransaction();
        fragmentTransaction.add(R.id.fragment,new CourseFragment());
        fragmentTransaction.commit();


    }
    public void  course(View view){
        courseImg= (ImageView) findViewById(id.course_img);
        courseText= (TextView) findViewById(id.course_text);
        courseImg.setImageResource(drawable.main_course_icon_selected);
        courseText.setTextColor(Color.parseColor("#ACCCF4"));
        exerciseImg= (ImageView) findViewById(id.exercise_img);
        exerciseText= (TextView) findViewById(id.exercise_text);
        exerciseImg.setImageResource(drawable.main_exercises_icon);
        exerciseText.setTextColor(Color.parseColor("#9C9C9C"));
        myImg= (ImageView) findViewById(id.my_img);
        myText= (TextView) findViewById(id.my_text);
        myImg.setImageResource(drawable.main_my_icon);
        myText.setTextColor(Color.parseColor("#9C9C9C"));
        fragmentManager=getFragmentManager();
        fragmentTransaction=fragmentManager.beginTransaction();
        fragmentTransaction.replace(R.id.fragment,new CourseFragment());
        fragmentTransaction.commit();
    }
    public void  exercise(View view){
        courseImg= (ImageView) findViewById(id.course_img);
        courseText= (TextView) findViewById(id.course_text);
        courseImg.setImageResource(drawable.main_course_icon);
        courseText.setTextColor(Color.parseColor("#9C9C9C"));
        exerciseImg= (ImageView) findViewById(id.exercise_img);
        exerciseText= (TextView) findViewById(id.exercise_text);
        exerciseImg.setImageResource(drawable.main_exercises_icon);
        exerciseText.setTextColor(Color.parseColor("#9C9C9C"));
        exerciseImg= (ImageView) findViewById(id.exercise_img);
        exerciseText= (TextView) findViewById(id.exercise_text);
        exerciseImg.setImageResource(drawable.main_exercises_icon_selected);
        exerciseText.setTextColor(Color.parseColor("#ACCCF4"));
        myImg= (ImageView) findViewById(id.my_img);
        myText= (TextView) findViewById(id.my_text);
        myImg.setImageResource(drawable.main_my_icon);
        myText.setTextColor(Color.parseColor("#9C9C9C"));
        fragmentManager=getFragmentManager();
        fragmentTransaction=fragmentManager.beginTransaction();
        fragmentTransaction.replace(R.id.fragment,new ExercisesFragment());
        fragmentTransaction.commit();
    }
    public void  my (View view){
        courseImg= (ImageView) findViewById(id.course_img);
        courseText= (TextView) findViewById(id.course_text);
        courseImg.setImageResource(drawable.main_course_icon);
        courseText.setTextColor(Color.parseColor("#9C9C9C"));
        exerciseImg= (ImageView) findViewById(id.exercise_img);
        exerciseText= (TextView) findViewById(id.exercise_text);
        exerciseImg.setImageResource(drawable.main_exercises_icon);
        exerciseText.setTextColor(Color.parseColor("#9C9C9C"));
        myImg= (ImageView) findViewById(id.my_img);
        myText= (TextView) findViewById(id.my_text);
        myImg.setImageResource(drawable.main_my_icon_selected);
        myText.setTextColor(Color.parseColor("#ACCCF4"));
        fragmentManager=getFragmentManager();
        fragmentTransaction=fragmentManager.beginTransaction();
        fragmentTransaction.replace(R.id.fragment,new MyFragment());
        fragmentTransaction.commit();
    }
}
